package net.homelinux.chaoswg.io.renga.core;

import net.homelinux.chaoswg.io.datatypes.Unit;
import net.homelinux.chaoswg.io.higherorderfunctions.AbstractConstantFunction;
import net.homelinux.chaoswg.io.renga.core.gui.operations.CompositeOperation;
import net.homelinux.chaoswg.io.renga.core.gui.operations.ConstantOperation;
import net.homelinux.chaoswg.io.renga.core.gui.operations.Control;
import net.homelinux.chaoswg.io.renga.core.gui.operations.FunctionInputOperation;
import net.homelinux.chaoswg.io.renga.core.gui.operations.FunctionOutputOperation;
import net.homelinux.chaoswg.io.renga.core.gui.operations.Operation;
import net.homelinux.chaoswg.io.renga.core.gui.operations.PrimitiveOperation;
import net.homelinux.chaoswg.io.renga.core.gui.operations.VariableGetOperation;
import net.homelinux.chaoswg.io.renga.core.gui.operations.VariablePutOperation;
import net.homelinux.chaoswg.io.renga.core.gui.operations.factories.CompositeOperationFactory;
import net.homelinux.chaoswg.io.renga.core.gui.operations.reader.CompositeOperationReader;
import net.homelinux.chaoswg.io.renga.core.gui.operations.reader.ConstantOperationReader;
import net.homelinux.chaoswg.io.renga.core.gui.operations.reader.FunctionInputOperationReader;
import net.homelinux.chaoswg.io.renga.core.gui.operations.reader.FunctionOutputOperationReader;
import net.homelinux.chaoswg.io.renga.core.gui.operations.reader.ImageVisualisationReader;
import net.homelinux.chaoswg.io.renga.core.gui.operations.reader.NamedBlockVisualisationReader;
import net.homelinux.chaoswg.io.renga.core.gui.operations.reader.PrimitiveOperationReader;
import net.homelinux.chaoswg.io.renga.core.gui.operations.reader.SplitBoxVisualisationReader;
import net.homelinux.chaoswg.io.renga.core.gui.operations.reader.VariableGetOperationReader;
import net.homelinux.chaoswg.io.renga.core.gui.operations.reader.VariablePutOperationReader;
import net.homelinux.chaoswg.io.renga.core.gui.operations.visualisations.ImageVisualisation;
import net.homelinux.chaoswg.io.renga.core.gui.operations.visualisations.NamedBlockVisualisation;
import net.homelinux.chaoswg.io.renga.core.gui.operations.visualisations.SplitBlockVisualisation;
import net.homelinux.chaoswg.io.renga.core.registries.OperationRegistry;
import net.homelinux.chaoswg.io.renga.core.registries.ReaderRegistry;
import net.homelinux.chaoswg.io.renga.krypto.gui.operations.LoopOperation;
import net.homelinux.chaoswg.io.renga.krypto.gui.operations.reader.LoopOperationReader;

public class Test extends AbstractConstantFunction<Unit> implements Initializer {
    public Unit apply () {
        ReaderRegistry orr = ReaderRegistry.getOperationRegistry();
        orr.setOperationReader(CompositeOperation.class, new CompositeOperationReader ());
        orr.setOperationReader(ConstantOperation.class, new ConstantOperationReader ());
        orr.setOperationReader(FunctionInputOperation.class, new FunctionInputOperationReader ());
        orr.setOperationReader(FunctionOutputOperation.class, new FunctionOutputOperationReader ());
        orr.setOperationReader(PrimitiveOperation.class, new PrimitiveOperationReader ());
        orr.setOperationReader(VariableGetOperation.class, new VariableGetOperationReader ());
        orr.setOperationReader(VariablePutOperation.class, new VariablePutOperationReader ());
        orr.setOperationReader(ImageVisualisation.class, new ImageVisualisationReader ());
        orr.setOperationReader(NamedBlockVisualisation.class, new NamedBlockVisualisationReader());

        orr.setOperationReader(SplitBlockVisualisation.class, new SplitBoxVisualisationReader ());

        OperationRegistry.getOperationRegistry().setOperationFactory("Composite Operation", new CompositeOperationFactory ().curry(new AbstractConstantFunction<Control> () { public Control apply () { return new Control (); } } ));

        OperationRegistry.getOperationRegistry().setOperationFactory("Binding Put", new AbstractConstantFunction<Operation> () {
            public Operation apply () {
                return new VariablePutOperation ();
            }
        });

        OperationRegistry.getOperationRegistry().setOperationFactory("Binding Get", new AbstractConstantFunction<Operation> () {
            public Operation apply () {
                return new VariableGetOperation ();
            }
        });

        OperationRegistry.getOperationRegistry().setOperationFactory("Constant", new AbstractConstantFunction<Operation> () {
            public Operation apply () {
                return new ConstantOperation ();
            }
        });

        return null;
    }
}
